/*
 *  POJ1015: Jury Compromise
 */

/*-------- Includes --------*/
#include <vector>
#include <cstring>
#include <iostream>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int dif[200];
int sum[200];

int dp[21][801];

vector<int> id[21][801];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int n, m;
    int kCase = 1;

    while (cin >> n >> m && n) {
        // get input
        int D, P;
        for (int i = 0; i < n; i++) {
            cin >> D >> P;
            dif[i] = D - P;
            sum[i] = D + P;
        }

        // initialize
        int base  = m * 20;
        int upper = m * 40;

        memset(dp, -1, sizeof(dp));

        dp[0][base] = 0;

        for (int i = 1; i <= m; i++) {
            int upper = m * 40;
            for (int j = 0; j <= upper; j++)
                id[i][j].clear();
        }

        for (int i = 0; i < n; i++) {   // i candidates
            for (int j = m; j > 0; j--) {  // i jury members
                for (int k = 0; k <= upper; k++) {  // for each diff status
                    if (dp[j - 1][k] == -1) continue;

                    int kk = k + dif[i];

                    if (dp[j][kk] < dp[j - 1][k] + sum[i]) {
                        dp[j][kk] = dp[j - 1][k] + sum[i];

                        id[j][kk] = id[j - 1][k];
                        id[j][kk].push_back(i);
                    }
                }
            }
        }

        // find minimum of diff and maximum of sum
        int r = 0;
        while (dp[m][base - r] == -1 && dp[m][base + r] == -1) r++;
        if (dp[m][base - r] > dp[m][base + r]) r = -r;

        int sumD = (dp[m][base + r] + r) / 2;
        int sumP = (dp[m][base + r] - r) / 2;

        vector<int> &vec = id[m][base + r];

        // print result
        cout << "Jury #" << kCase++ << endl;
        cout << "Best jury has value " << sumD << " for prosecution and value "
             << sumP << " for defence: " << endl;
        for (int i = 0; i < m; i++)
            cout << " " << vec[i] + 1;
        cout << endl << endl;
    }

    return 0;
}

/*-------- Functions --------*/

